package com.ganzi.manager.activiti.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;

import java.util.Iterator;
import java.util.Map;

/**
 * @author lxd
 * @create 2019/7/5
 */
public class JsonMapUtil {
    //审批同意或拒绝表单字段
    public static final String ALLOW ="zmdActivitiAllow";
    //审批人参数变量
    public static final String TASK_USER ="zmdActivitiTaskUser";
    //默认审核表单Key
    public static final String DE_NOTE_FORMKEY ="defaultNoteFormKey";

    public static JSONObject toJsonObj(Map<String, Object> map) {
        if(map == null){return null;}
        JSONObject resultJson = new JSONObject();
        Iterator it = map.keySet().iterator();
        while (it.hasNext()) {
            String key = (String) it.next();
            resultJson.put(key, map.get(key));
        }
        return resultJson;
    }
    public static Map<String,Object> toMapObj(String str) {
        if(StringUtils.isBlank(str)){return null;}
        Map<String,Object> object = (Map) JSON.parseObject(str);
        return object;
    }
}
